/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ifconnect.model.dao;

import ifconnect.model.entity.Curso;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Genemes
 */
public class CursoDao extends DaoGenerico implements Serializable{
    
    public CursoDao(){
        super();
    }
    
    public boolean cadastroCurso(Curso curso) {
        try {
            this.salvar(curso);
            return true;
        } catch (Exception ex) {
            ex.printStackTrace();
            this.getEntityManager().getTransaction().rollback();
            return false;
        }
    }

    public boolean excluirCurso(Long id) {
        Curso c = null;
        try {
            c = this.buscar(Curso.class, id);
            this.remover(c);
            return true;
        } catch (Exception ex) {
            ex.printStackTrace();
            this.getEntityManager().getTransaction().rollback();
            return false;
        }
    }
    
    public List<Curso> listar(){
        List<Curso> listaCurso = new ArrayList<Curso>();
        listaCurso = this.listarTodos(Curso.class);
        return listaCurso;
    }
    
    public Curso porcurarPorAtributo(String atributo, String value){
        Curso c = this.buscarPorAtributo(Curso.class, atributo, value);
        return c;
    }
}
